<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="viewport"
	content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<title>邮宝洗衣</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css">
<link href="../../css/type.css" rel="stylesheet" type="text/css">
<style type="text/css">
/*<![CDATA[*/
* html .decoration {
	position: absolute;
	right: 16px;
	top: 0;
} /*only for ie*/
/*]]>*/
</style>
<!-- Do not move the bellow script to custom.js! It must stay here to
    load properly! -->
<script type="text/javascript" src="../../scripts/jquery.js"></script>
<script type="text/javascript" src="../../scripts/custom.js" charset="utf-8"></script>
<script type="text/javascript" src="../../scripts/jquerysession.js"></script>
<script type="text/javascript" src="../../scripts/layer/layer.m.js"></script>
</head>
<body onLoad="loadImages()">
	<p class="no-mobile">
		请使用手机访问本页面！ <br /> 这个页面是专门针对手机设计的！
	</p>
	<div class="site">
		<div id="hidepage">
			<p class="center-text">
				加载中，请耐心等待! <br /> <img src="../../images/background/130.gif"
					alt="load">
			</p>
		</div>
	<div class="decoration">
			<div class="back">
				<a href="../../index.jsp">
					<img src="../../images/home/back.png">
				</a>
			</div> 
			<p class="title" style="width: 33%;float: left;">我要洗衣</p>
			<div style="width: 33%">
				<a href="#">
					<img src="../../images/refresh.png">
				</a>
			</div> 
	</div>
	<div id="wrapper">

		<div class="msg">
			<p>请您完善<font color="#ff6c0d">收衣方式</font>、服务时间和收送地址，方便我们更好的为您服务</p>
		</div>
		
		<div class="home_table">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td class="data" colspan="2" style="border-bottom: 1px solid #a0a0a0;">
					<p class="home_addr_title">收送地址</p>
					<div class="home_addr_btn">
						<a href="../person/addrmanage.jsp"> 
							<img src="../../images/home/selectaddress.png">
						</a>
					</div>
					</td>
				</tr>
				<tr>
					<td class="data" colspan="2" style="border-bottom: 1px solid #a0a0a0;">
						<p class="home_table_tdaddr"></p>
					</td>
				</tr>
				<tr>
					<td
						style="border-right: 1px solid #a0a0a0; border-bottom: 1px solid #a0a0a0;">联系方式</td>
					<td class="data" style="border-bottom: 1px solid #a0a0a0;">
					</td>
				</tr>
				<tr>
					<td
						style="border-right: 1px solid #a0a0a0; border-bottom: 1px solid #a0a0a0;">上门日期</td>
					<td class="data" style="border-bottom: 1px solid #a0a0a0;">
						<div class="ui-select">
							<select>
							</select>
						</div> 
					</td>
				</tr>
				<tr>
					<td style="border-right: 1px solid #a0a0a0;">服务时间段</td>
					<td class="data">
						<div class="ui-select">
							<select>
							</select>
						</div>
					</td>
				</tr>
				<tr>
					<td class="data" colspan="2" style="border-top: 1px solid #a0a0a0;">
						<div class="select">
							<input type="radio" checked="checked" name="send" id="person"
								value="0"> <label name="person" class="lchecked"
								>等待上门收衣</label> <input type="radio" disabled="disabled"
								name="send" value="1" id="box"> <label name="box"
								class="lnotchecked" >放在收衣柜中</label>
						</div>
					</td>
				</tr>
			</table>
		</div>
		<div class="next_lag">
			<a href="javascript:void(0)">
				<img src="../../images/home/next_lag.png">
			</a>
		</div> 
		
		<!--order end-->
	</div>
	</div>
	<script type="text/javascript">
	 $(document).ready(function () {
		 	var dateOpinion = getDateString();
		 	var timeOpinion = getTimeString('0');
		 	var addr = decodeURIComponent($.session.get("receiveAddr"));
		 	var name = decodeURIComponent($.session.get("name"));
		 	var mobileNum = decodeURIComponent($.session.get("mobileNum"));
		 	$(".ui-select:eq(0)").find("select").html(dateOpinion);
		 	$(".ui-select:eq(1)").find("select").html(timeOpinion);
		 	if(addr!="null"&&name!="null"&&mobileNum!="null"){
		 		$(".home_table_tdaddr").html(addr);
		 		$(".data:eq(2)").html("<p>"+name+"</p><p>"+mobileNum+"</p>");
		 	}else{
			 	$.post("../../transaction/querySingleTradeAddr?funcID=0002&platformId="+$.session.get("platformId"), function(v) {
			 		if(v.tradeAddrList.length==0){
						layer.open({content: '请先设置地址！',time: 2,end: function(){location.href = "../person/newaddr.jsp?status=2";}});
					}
					for(var i=0;i<v.tradeAddrList.length;i++){
						var tradeAddrs = v.tradeAddrList[i];
						if(tradeAddrs.status=='2'){
							$(".home_table_tdaddr").html(tradeAddrs.province+tradeAddrs.city+tradeAddrs.area+tradeAddrs.street+tradeAddrs.addr);
							$(".data:eq(2)").html("<p>"+tradeAddrs.name+"</p><p>"+tradeAddrs.mobileNum+"</p>");
						}
					}
				});
		 	}
		});
	 $(".ui-select:eq(0)").find("select").live("change",function(){
		 $(".ui-select:eq(1)").find("select").html(getTimeString($(this).val()));
	 });
	 $(".next_lag").live("click",function(){
		 var getType = $(".select").val();
		 var receiveAddr = $(".home_table_tdaddr").html();
		 var dateVal = $(".ui-select:eq(0)").find("select").val();
		 var startTime = $(".ui-select:eq(1)").find("select").val();
		 var date = new Date();
		 date.setDate(date.getDate()+parseInt(dateVal));
		 date.setHours(parseInt(startTime),0,0,0);
		 var receiveOrderTimeStart = date.Format("yyyy-MM-dd hh:mm:ss");
		 date.setHours((parseInt(startTime)+2),0,0,0);
		 var receiveOrderTimeEnd = date.Format("yyyy-MM-dd hh:mm:ss");
		 if(receiveAddr==""){
			 layer.open({content: '请选择收送地址！',time: 2});
		 }else{
			 $.session.set('getType', getType);
			 $.session.set('receiveAddr', receiveAddr);
			 $.session.set('receiveOrderTimeStart', receiveOrderTimeStart);
			 $.session.set('receiveOrderTimeEnd', receiveOrderTimeEnd);
			 location.href = "sendcloth.jsp";
		 }
	 });
	 function getDateString(){
		 var date = new Date();
		 var str = "";
		 if(date.getHours()>=18){
			 date.setDate(date.getDate()+1);
			 str = "<option value='1' selected='selected'>"+date.Format("yyyy-MM-dd")+"</option>";
			 for(var i=2;i<=5;i++){
				 date.setDate(date.getDate()+1);
				 str += "<option value='"+i+"'>"+date.Format("yyyy-MM-dd")+"</option>";
			 }
		 }else{
			 str = "<option value='0' selected='selected'>"+date.Format("yyyy-MM-dd")+"</option>";
			 for(var i=1;i<=4;i++){
				 date.setDate(date.getDate()+1);
				 str += "<option value='"+i+"'>"+date.Format("yyyy-MM-dd")+"</option>";
			 }
		 }
		 return str;
	 }
	 function getTimeString(time){
		 var date = new Date();
		 var str = "";
		 if(time=='0'){
			 var hour = date.getHours();
			 if(hour>=18){
				 for(var i=8;i<=18;i+=2){
					 str += "<option value='"+i+"'>"+i+":00--"+(i+2)+":00"+"</option>";
				 }
			 }else{
				 if(hour%2==1){hour-=1;}
				 if(hour<8){hour=8;}
				 hour+=2;
				 for(var i=hour;i<=18;i+=2){
					 str += "<option value='"+i+"'>"+i+":00--"+(i+2)+":00"+"</option>";
				 }
			 }
		 }else{
			 for(var i=8;i<=18;i+=2){
				 str += "<option value='"+i+"'>"+i+":00--"+(i+2)+":00"+"</option>";
			 }
		 }
		 return str;
	 }
	</script>
</body>
</html>